import { request } from '../../request';

/**
 * 新增菜单
 *
 * @param menu 菜单数据
 * @returns
 */
export function fetchAddMenu(menu: Api.System.Menu) {
  return request<null>({
    url: '/menu',
    method: 'post',
    data: menu
  });
}

/**
 * 更新菜单
 *
 * @param menu 菜单数据
 * @returns
 */
export function fetchUpdateMenu(menu: Api.System.Menu) {
  return request<null>({
    url: '/menu',
    method: 'put',
    data: menu
  });
}

/**
 * 删除菜单
 *
 * @param menu 菜单数据
 * @returns
 */
export function fetchDeleteMenu(id: number) {
  return request<null>({
    url: `/menu/${id}`,
    method: 'delete'
  });
}

/**
 * 获取菜单树
 *
 * @param menu 菜单数据
 * @returns
 */
export function fetchGetMenuTree(menuType?: string) {
  return request<Api.System.MenuTree[]>({
    url: `/menu/treeselect`,
    method: 'get',
    params: {
      menuType
    }
  });
}
